← C++ 高级程序设计(2020)

2020-C++高级程序设计-C++ 输入重定向到文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream>
#include<string>
#include<sstream>
#include<fstream>
using namespace std;
int main() {
string str1;
string str2;
getline(cin, str1);
getline(cin, str2);
string str = str1 + "\n" + str2;
std::ofstream f("D:\\answer\\answer.txt", std::ios::app);
f << str << std::endl;
f.close();
}

1. 考试注意事项

  1. 多次扩容,嵌套操作
  2. int输入可能导致内部 long long
返回「C++ 高级程序设计(2020)」课程目录 →

上一篇课程笔记

2020-C++高级程序设计-C++ 输入输出

下一篇课程笔记

2020-C++高级程序设计-C++ 数据

评论